#ifndef DATAHANDLE_H
#define DATAHANDLE_H
#include <QString>
#include <QMutex>
#include <QMutexLocker>



//16进制和浮点型相互转换
typedef union _HexToFloat{
    unsigned char hex[4];
    float dataf;
}_HexToFloat;

//CRC校验
unsigned short int CheckCRC_16(const  unsigned char* data,const unsigned int sIndex=0,const unsigned int length=0);//CRC校验
unsigned short int CheckCRC_16(const  QByteArray &dataByte,const unsigned int sIndex=0,const unsigned int length=0);//CRC校验
void CheckCRC_16_add(QByteArray &dataByte,const unsigned int sIndex=0,const unsigned int length=0);//给字节数组添加CRC校验

bool CheckCRC_16_IsOk(const  unsigned char* data,const unsigned int sIndex=0,const unsigned int length=0);//判断字节数据的校验值是否对
bool CheckCRC_16_IsOk(const  QByteArray &dataByte,const unsigned int sIndex=0,const unsigned int length=0);//判断字节数据的校验值是否对
unsigned short int CheckSum_8(const  unsigned char* data,const unsigned int sIndex=0,const unsigned int length=0);//校验和计算
unsigned short int CheckSum_8(const  QByteArray &dataByte,const unsigned int sIndex=0,const unsigned int length=0);//校验和计算

QVector<QByteArray> QByteArraySplit(const QByteArray &SrcByteArray=QByteArray(),const int Count=0);//数组分割
QList<QByteArray> QByteArraySplitChar(const QByteArray &SrcByteArray=QByteArray(),const QByteArray Split=QByteArray());//数组分割

#endif // DATAHANDLE_H
